#ifndef POOL_H__
#define POOL_H__

#include <map>
#include <string>
#include <fstream>

using std::map;
using std::string;
using std::istream;
using std::ifstream;

template<typename T>
class Pool {
protected:
	map<string, T> pool;

public:
	Pool() = default;
	~Pool() = default;

	void loadFile(string);
	virtual void load(istream&) = 0;
	T& get(string);
	void clear();
};

template<typename T>
void Pool<T>::loadFile(string fileName) {
	ifstream input(fileName);
	load(input);
}

template<typename T>
T& Pool<T>::get(string name) {
	return pool[name];
}

template<typename T>
void Pool<T>::clear() {
	pool.clear();
}

#endif //POOL_H__